import FormDesignEntity from './item/FormDesignEntity'
import OperationEntity from './item/OperationEntity'
import ApiEntity from './item/ApiEntity'
import OperationDisplayEntity from './item/OperationDisplayEntity'
import { is } from 'bpmn-js/lib/util/ModelUtil'

const LOW_PRIORITY = 500

export default function FormPropertiesProvider(propertiesPanel, translate) {
  this.getGroups = function (element) {
    return function (groups) {
      if (is(element, 'bpmn:StartEvent') || is(element, 'bpmn:UserTask')) {
        const formGroup = {
          id: 'skrivetFormSetting',
          label: translate('Form Setting'),
          entries: [FormDesignEntity(element), OperationDisplayEntity(element)]
        }
        if (is(element, 'bpmn:UserTask')) {
          formGroup.entries.push(OperationEntity(element))
          formGroup.entries.push(ApiEntity(element))
        }
        groups.push(formGroup)
      }

      return groups
    }
  }
  propertiesPanel.registerProvider(LOW_PRIORITY, this)
}

FormPropertiesProvider.$inject = ['propertiesPanel', 'translate']
